#pragma once

#include <sys/types.h>
#include <stdio.h>
#include <sys/stat.h>
#include <cstdlib>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>
#include <string>

enum
{
    MKFIFO_CREATE_ERR = 1,
    MKFIFO_OPEN_ERR,
    MKFIFO_UNLINK_ERR,
    FIFO_DELETE_ERR
};

class Init
{
public:
    Init()
    {
        int n = mkfifo("mkfifo", 0666);
        if (n == -1)
        {
            perror("makfifo");
            exit(MKFIFO_CREATE_ERR);
        }
    }

    ~Init()
    {
        int m = unlink("mkfifo");
        if (m == -1)
        {
            perror("unlink");
            exit(FIFO_DELETE_ERR);
        }
    }
};